import React from 'react';
import {FC,ReactElement} from "react";
import {Navigate} from "react-router-dom";
import {useSelectAuth} from "@/store/slice/auth";

type TProps = {
    children: ReactElement
}

// const  AuthComponent:FC<any> = props => localStorage.getItem('token') ? props.children : <Navigate to={'/login'}></Navigate>
// const  AuthComponent:FC<TProps> = props => localStorage.getItem('token') ? props.children : <Navigate to={'/login'}></Navigate>
const  AuthComponent:FC<TProps> = props => {
    const {token} = useSelectAuth()
    return token ? props.children : <Navigate to={'/login'}></Navigate>
}
export default AuthComponent;